cc.Class({
  extends: cc.Component,
  properties: {
    EndlessGameCtl: require('../../controller/EndlessCtl')
  },

  onLoad() {
  },

  onBeginContact(contact, self, other) {
    // console.log(contact, self, other);
    if (other.node.name === 'Npc') {
      console.log('碰撞到底部');
      //碰撞到了底部
      this.EndlessGameCtl.EndlessGameModel.NpcBallSign++;
      if (
        this.EndlessGameCtl.EndlessGameModel.NpcBallSign ===
        this.EndlessGameCtl.EndlessGameModel.NpcBall
      ) {
        // 最后一个球哦
        this.EndlessGameCtl.EndlessGameModel.isMoveDown = true; //每发射一次则触发一次砖块下移的动作
        this.EndlessGameCtl.EndlessGameModel.LastNpcPositionX = other.node.x;

        // 需要重置一下
        this.EndlessGameCtl.EndlessGameModel.NpcBallSign = 0;
        this.EndlessGameCtl.EndlessGameModel.isActive = false;
      }
      other.node.destroy();
    }
  }
});
